package com.ruoyi.customer.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.customer.domain.CustomerReport;
import com.ruoyi.customer.mapper.CustomerReportMapper;
import com.ruoyi.customer.service.ICustomerReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 投诉建议 业务层处理
 * 
 * @author ruoyi
 */
@Service
public class CustomerReportServiceImpl implements ICustomerReportService
{
    @Autowired
    private CustomerReportMapper customerReportMapper;

    /**
     * 根据条件分页查询投诉建议列表
     * 
     * @param customerReport 投诉建议信息
     * @return 投诉建议信息集合信息
     */
    @Override
    @DataScope(orderAlias = "o", userAlias = "u")
    public List<CustomerReport> selectCustomerReportList(CustomerReport customerReport)
    {
        return customerReportMapper.selectCustomerReportList(customerReport);
    }

    /**
     * 通过投诉建议ID查询投诉建议
     *
     * @param id 投诉建议ID
     * @return 投诉建议对象信息
     */
    @Override
    public CustomerReport selectCustomerReportById(Long id)
    {
        return customerReportMapper.selectCustomerReportById(id);
    }

    /**
     * 新增保存投诉建议信息
     * 
     * @param customerReport 投诉建议信息
     * @return 结果
     */
    @Override
    @Transactional
    public int insertCustomerReport(CustomerReport customerReport)
    {
        Long userId = SecurityUtils.getUserId();
        customerReport.setCustomerUserId(userId);
        int rows = customerReportMapper.insertCustomerReport(customerReport);
        return rows;
    }

    /**
     * 修改保存投诉建议信息
     * 
     * @param customerReport 投诉建议信息
     * @return 结果
     */
    @Override
    @Transactional
    public int updateCustomerReport(CustomerReport customerReport)
    {
        return customerReportMapper.updateCustomerReport(customerReport);
    }

    /**
     * 批量删除投诉建议信息
     * 
     * @param reportIds 需要删除的投诉建议编号
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteCustomerReportByReportIds(Long[] reportIds)
    {
        return customerReportMapper.deleteCustomerReportByReportIds(reportIds);
    }
}
